import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
import java.util.logging.Level;
import java.util.logging.Logger;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Dimitris
 */
public class Create {

    public static void main(String args[]) {
        try {

            //   File greekInput = new File("europarl-v6.el-en.el");

            for (int i = 5; i <= 100; i += 5) {
                RandomAccessFile fromFile = new RandomAccessFile("spanish100.txt", "rw");
                System.out.println(i);
                long position = (fromFile.length() / 100)*i;
                long count = fromFile.length()-(fromFile.length() / 100) * i;
                fromFile.seek(position);
                FileChannel fromChannel = fromFile.getChannel();
                
                RandomAccessFile toFile = new RandomAccessFile("spanishTest/spanish" + i + ".txt", "rw");
                
                FileChannel toChannel = toFile.getChannel();
               
                   
                toChannel.transferFrom(fromChannel, 0, count);
                toChannel.close();
                toFile.close();
            }

            for (int i = 5; i <= 100; i += 5) {
                RandomAccessFile fromFile = new RandomAccessFile("english100.txt", "rw");
                System.out.println(i);
long position = (fromFile.length() / 100)*i;
                long count = fromFile.length()-(fromFile.length() / 100) * i;
                fromFile.seek(position);

                FileChannel fromChannel = fromFile.getChannel();

                RandomAccessFile toFile = new RandomAccessFile("englishTest/english" + i + ".txt", "rw");
                FileChannel toChannel = toFile.getChannel();
                
                   
                toChannel.transferFrom(fromChannel, 0, count);
                toFile.close();
            }
            for (int i = 5; i <= 100; i += 5) {
                RandomAccessFile fromFile = new RandomAccessFile("greek100.txt", "rw");
                System.out.println(i);
                long position = (fromFile.length() / 100)*i;
                long count = fromFile.length()-(fromFile.length() / 100) * i;
                fromFile.seek(position);
                FileChannel fromChannel = fromFile.getChannel();

                RandomAccessFile toFile = new RandomAccessFile("greekTest/greek" + i + ".txt", "rw");
                FileChannel toChannel = toFile.getChannel();
                
                toChannel.transferFrom(fromChannel, 0, count);
                toFile.close();
            }
        } catch (IOException ex) {
            Logger.getLogger(Create.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
